from ttk import Frame, Button, Style
from Tkinter import Tk, BOTH
import tkMessageBox as box

class MessageBox(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent        
        self.initUI()
        
    def initUI(self):
        self.parent.title("Message boxes")
        self.style = Style()
        self.style.theme_use("default")        
        self.pack()
        
        error = Button(self, text="Error", command=self.onError)
        error.grid()
        
        warning = Button(self, text="Warning", command=self.onWarn)
        warning.grid(row=1, column=0)
        
        question = Button(self, text="Question", command=self.onQuest)
        question.grid(row=0, column=1)
        
        inform = Button(self, text="Information", command=self.onInfo)
        inform.grid(row=1, column=1)
        
    def onError(self):
        box.showerror("Error", "Could not open file")
    
    def onWarn(self):
        box.showwarning("Warning", "Deprecated function call")
        
    def onQuest(self):
        if box.askquestion("Question", "Are you sure to quit?") == box.YES:
            quit()
        
    def onInfo(self):
        box.showinfo("Information", "Download completed")
            
def main():
  
    root = Tk()
    ex = MessageBox(root)
    root.geometry("300x150+300+300")
    root.mainloop()  


if __name__ == '__main__':
    main()  
            